package com.wltt.product.ahuthr.service;

import com.wltt.product.ahuthr.mapper.SystemAgreementTypeMapper;
import com.wltt.product.ahuthr.model.ResultData;
import com.wltt.product.ahuthr.model.po.SystemAgreementTypePO;
import com.wltt.product.ahuthr.model.vo.AgreementTypeRsp;
import com.wltt.product.ahuthr.service.base.BaseServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;


/**
 * @ClassName: SystemAgreementTypeServiceImpl
 * @Description: 系统协议类型 逻辑服务类<br/>
 * 不做业务校验，参数校验统一放到前置的Service中
 * @Date: 2024-08-07 09:50:27
 * @Author yanggl
 */
@Service(value = "systemAgreementTypeService")
public class SystemAgreementTypeServiceImpl extends BaseServiceImpl<SystemAgreementTypePO, Long> implements SystemAgreementTypeService {

    private SystemAgreementTypeMapper systemAgreementTypeMapper;

    //构造方法
    public SystemAgreementTypeServiceImpl(SystemAgreementTypeMapper systemAgreementTypeMapper) {
        super(systemAgreementTypeMapper);
        this.systemAgreementTypeMapper = systemAgreementTypeMapper;
    }

    /**
     * 查询列表
     *
     * @return
     */
    @Override
    public ResultData listAll() {
        List<SystemAgreementTypePO> poList = systemAgreementTypeMapper.queryAll();
        List<AgreementTypeRsp> rspList = Optional.ofNullable(poList).orElse(new ArrayList<>())
                .stream().map(po -> {
                    AgreementTypeRsp rsp = new AgreementTypeRsp();
                    BeanUtils.copyProperties(po, rsp);
                    return rsp;
                }).toList();
        return ResultData.success(rspList);
    }
}